package org.jeecg.modules.relation.relcourseplanapp.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.modules.courseplanatom.entity.CouCoursePlanAtom;
import org.jeecg.modules.relation.relcourschetempapp.entity.RelCourScheTempApp;
import org.jeecg.modules.relation.relcourschetempapp.mapper.RelCourScheTempAppMapper;
import org.jeecg.modules.relation.relcourseplanapp.entity.RelCoursePlanApp;
import org.jeecg.modules.relation.relcourseplanapp.mapper.RelCoursePlanAppMapper;
import org.jeecg.modules.relation.relcourseplanapp.service.IRelCoursePlanAppService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.List;

/**
 * @Description: rel_course_plan_app
 * @author: baochangrong
 * @Date:   2022-02-17
 * @Version: V1.0
 */
@Service
public class RelCoursePlanAppServiceImpl extends ServiceImpl<RelCoursePlanAppMapper, RelCoursePlanApp> implements IRelCoursePlanAppService {
    @Autowired
    private RelCoursePlanAppMapper relCoursePlanAppMapper;

    @Override
    public IPage<RelCoursePlanApp> allList(Page<RelCoursePlanApp> page, RelCoursePlanApp relCoursePlanApp) {
        List<RelCoursePlanApp> list = relCoursePlanAppMapper.queryAll(page, relCoursePlanApp);
        for (RelCoursePlanApp app : list) {
            int type = app.getRelObjTtype();
            if (1 <= type && type <= 5) {
                String objectName = relCoursePlanAppMapper.queryObjectNameByObjectId(type, app.getRelObjId());
                app.setObjectName(objectName);
            }
        }
        return page.setRecords(list);
    }
    /**
     * 升级教学计划下发
     * @param relCoursePlanApp
     * @return
     */
    @Override
    public int insertUpgradeRelCoursePlanApp(RelCoursePlanApp relCoursePlanApp){
        return relCoursePlanAppMapper.insertUpgradeRelCoursePlanApp(relCoursePlanApp);
    }
}
